<template>
	<div>
		<h1><strong>{{authorInfo.penName}}</strong></h1>
		<el-divider><i class="el-icon-monitor"></i></el-divider>
		<table width="100%" >
			<tr height="40px">
				<td>作者笔名：</td>
				<td>{{authorInfo.penName}}</td>
			</tr>
			<tr v-if="authorInfo.level=='签约写手'" height="40px">
				<td width="9%">签约状态：</td>
				<td>已签约 - - <router-link to="/author/agreement" class="link">作家协议</router-link></td>
			</tr>
			<tr v-if="authorInfo.level=='申请签约'"  height="40px">
				<td width="9%">签约状态：</td>
				<td>申请签约中 - - <router-link to="/author/agreement" class="link">作家协议</router-link></td>
			</tr>
			<tr v-else  height="40px">
				<td width="9%">签约状态：</td>
				<td>未签约 - - <router-link to="/author/signApply" class="link">申请签约</router-link>&nbsp;<router-link to="/author/agreement" class="link">作家协议</router-link></td>
			</tr>
			<tr height="40px">
				<td>责任编辑：</td>
				<td>{{authorInfo.editorId}}</td>
			</tr>
			<tr height="140px">
				<td>个人简介：</td>
				<td>
					<el-input type="textarea" maxlength="80" rows="5" v-model="authorInfo.description"></el-input>
				</td>
			</tr>
			<tr height="60px">
				 <td></td>
				 <td><el-button class="button" @click="Onsubmit">保存</el-button></td>
			</tr>
		</table>
	</div>
</template>

<script>
	import $ from 'jquery'
	export default {
		data() {
			return {
				authorInfo:[],
			}
		},
		methods: {
			init:function(){
				var _this=this;
				$.ajax({
					url:"http://localhost/author/"+(Number)(sessionStorage.getItem("authorId")),
					type:"get",
					contentType:"application/json;charset=utf-8",
					success:function(data){
						_this.authorInfo=data.data;
					}
				});
			},
			Onsubmit: function() {
				var _this = this;
				console.log(this.authorInfo)
				$.ajax({
					url: "http://localhost/author",
					type: "post",
					data: JSON.stringify(_this.authorInfo),
					contentType: "application/json;charset=utf-8",
					success: function(data) {
						if (data.code == "200") {
							alert("保存成功");
						}
					}
				})
			},
		},
		created() {
			this.init();
		},
	}
</script>

<style>
	.button{
		background-color: #52C29A;
		color: white;
	}
	.link{
		color: #52C29A;
	}
</style>
